package com.guigu.controller.manufacture;


import com.guigu.pojo.manufacture.MProcedureUnit;
import com.guigu.service.manufacture.MProcedureUnitService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Mr.Zhang
 * @since 2024-12-25
 */
@Controller
@RequestMapping("/m-procedure-unit")
public class MProcedureUnitController {

    @Autowired
    private MProcedureUnitService mProcedureUnitService;

    @GetMapping("/SetProductionProcessItems")
    private String SetProductionProcessItems() {
        return "jsp/manufacture/a/Set_production_process_items";
    }

    @GetMapping("/initialProcedureTable")
    @ResponseBody
    public ArrayList<MProcedureUnit> initialProcedureTable() {
        ArrayList<MProcedureUnit> mProcedureUnits = mProcedureUnitService.SelectAll();
        return mProcedureUnits;
    }

    @GetMapping("/getProcessById")
    @ResponseBody
    public MProcedureUnit getProcessById(HttpServletRequest req) {
        Integer id = StringUtils.isNotBlank(req.getParameter("id")) ? Integer.parseInt(req.getParameter("id")) : null;
        MProcedureUnit mProcedureUnit = mProcedureUnitService.SelectById(id);
        return mProcedureUnit;
    }
}

